<?php
namespace App\Models\WechatMsg;

use App\Models\RewardTimeHistory;
use App\Models\UserClock;
use App\Models\UserProject;
use App\Models\UserTeam;

class AddReward
{
    public  $type;
    public $content;

    public function __construct($type, $content)
    {
        $this->content = $content;
        $this->type = $type;
    }

    public function getOrgWechatConfig()
    {
        $addRecord = RewardTimeHistory::where('id', $this->content['reward_time_history_id'])->first();

        $conf['templateId'] = $addRecord->user->org->wechat_message_config['reward_time_vol'];

        $options = config('wechat');

        $options['app_id'] = $addRecord->user->org->wechat_app_id;
        $options['secret'] = $addRecord->user->org->wechat_app_secret;

        $conf['options'] = $options;

        $conf['openId'] = $addRecord->user->open_id;

        $conf['url'] = $addRecord->user->org->getBaseUrl().'/my/duration';
        return $conf;
    }


    public function getMessageData()
    {
        $addRecord = RewardTimeHistory::where('id', $this->content['reward_time_history_id'])->first();

        $data['first'] = "项目管理员为您记录了志愿时长";

        $data['keyword1'] =  "{$addRecord->project->name}";
        $data['keyword2'] = '志愿者';
        $data['keyword3'] = $addRecord->reward_time.'小时';
        $data['remark'] = '点击查看志愿时长记录';

        return $data;
    }
}